Overview
The Password Generator backend is built with Django 5.1 and Django REST Framework. It provides JWT authentication, password generation APIs, and user management.Prerequisites
- Python 3.10 or higher
- PostgreSQL database (for production)
- pip package manager
- Git
Dependencies
The backend requires the following Python packages:requirements.txt
Installation
Configure environment variables
Create a
.env file in the backend directory. See the Environment Configuration page for details..env
Database Setup
Development (SQLite)
For local development, Django uses SQLite by default:settings.py
Production (PostgreSQL)
For production, configure PostgreSQL:Database Migration
WSGI Configuration
The application uses WSGI for synchronous requests:backend/wsgi.py
ASGI Configuration
For asynchronous support, the application includes ASGI configuration:backend/asgi.py
Running the Server
Development Server
http://localhost:8000/api/.
Production with Gunicorn
Docker Deployment
The project includes a production-ready Dockerfile:Dockerfile
Fly.io Deployment
The project includes configuration for Fly.io:fly.toml
Static Files Configuration
The project uses WhiteNoise for serving static files:settings.py
Health Checks
Create a health check endpoint for monitoring:apps/password_generator/views.py
urls.py:
Monitoring and Logging
Configure Logging
Add tosettings.py:
Troubleshooting
Database Connection Issues
If you encounter database connection errors:Static Files Not Loading
CORS Errors
Verify CORS settings in.env:
Security Checklist
- Set
DEBUG=Falsein production - Use a strong, random
SECRET_KEY - Configure
ALLOWED_HOSTSproperly - Use HTTPS (enable
SECURE_SSL_REDIRECT) - Set up CORS correctly
- Use PostgreSQL instead of SQLite
- Enable database SSL (
ssl_require=True) - Keep dependencies updated
- Use environment variables for secrets
- Set up rate limiting for APIs
Next Steps
Frontend Deployment
Deploy the Next.js frontend
Environment Configuration
Configure environment variables
